package com.freewater.springboot.demo.ioc.value;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
@ComponentScan
@PropertySource("classpath:com/freewater/springboot/demo/ioc/value/application.properties")
public class AppConfig {
    /**
     * PropertySourcesPlaceholderConfigurer本身是一个BeanFactoryPostProcessor，所以这里方法要为static的
     * 默认情况如果没有找到占位符对应的值会报错
     */
    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }
}
